下面程序只保留 " 建套接字 —`connect`— 发 GET— 读响应取状态码 — 关闭 " 的结构。目标固定为回环地址 `127.0.0.1`,端口从命令行参数读取、缺省 8080。路径样本仅取 `/`、`/index.html`、`/login` 三条通用占位串,不携带真实字典,不针对外部目录。每个调用失败都经 `perror` 判错并释放描述符。 ``` #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> /* 对回环地址的一条路径样本发起一次 GET,解析响应状态码 */ static int probe_path(int port, const char *path) { /* 创建 IPv4/TCP 套接字,失败返回 -1 */ int fd = socket(AF_INET, SOCK_STREAM,